<?php

namespace app\index\handler;

use app\common\model\User;
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;

class TextMessageHandler implements EventHandlerInterface
{
    public function handle($payload = null)
    {
        $user = User::where('openid', $payload['FromUserName'])->findOrEmpty();
        if ($user->isEmpty()) {
            return '你不是系统用户';
        } else {
            return '您的昵称: ' . $user->nickname;
        }
    }
}
